package com.his.dao.jpa;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import com.his.pojos.jpa.HisEmployee;
import com.his.vo.CallingVO;

public interface MxjEmployeeDAO extends CrudRepository<HisEmployee, Long> {
	public List<HisEmployee> findByygPost(String ygpost);
	
	@Query("select ygNo from HisEmployee where ygName=:ygName")
	public BigDecimal findygNoByygName(@Param("ygName")String ygName);
	
	@Query("select e.ygNo from HisEmployee e,HisDoctor d"
			+ " where e.ygNo=d.ygNo and e.ygPost=:ygPost and d.ssNo=:ssNo")
	public long findAygNodb(@Param("ygPost")String ygPost,@Param("ssNo")BigDecimal ssNo);
	
	@Query("select new com.his.vo.CallingVO(rf.ghNo,mc.brName) from HisEmployee e, HisRegistrationForm rf, "
			+ "HisMedicalCard mc where "
			+ "rf.ylkNo=mc.ylkNo and rf.ygNo=e.ygNo and e.ygName=:ygName and e.ygPsd=:ygPsd")
	public List<CallingVO> findByygNameAndygPsd(@Param("ygName")String ygName,@Param("ygPsd")String ygPsd);
	
	@Query("select count(*) from HisEmployee e, HisRegistrationForm rf, "
			+ "HisMedicalCard mc where "
			+ "rf.ylkNo=mc.ylkNo and rf.ygNo=e.ygNo and e.ygName=:ygName and e.ygPsd=:ygPsd")
	public int vocount(@Param("ygName")String ygName,@Param("ygPsd")String ygPsd);
	
}
